package com.earthea.application.task;

import com.earthea.application.task.entity.Task;
import com.earthea.application.task.entity.TaskConstants;

import java.util.Collections;
import java.util.List;

public interface TaskService {

    int addTask(List<Task> tasks);

    default int addTask(Task task) {
        return addTask(Collections.singletonList(task));
    }

    List<Task> poll(String type, String label, int limit);

    default List<Task> poll(String type, String label) {
        return poll(type, label, TaskConstants.DEFAULT_POLL_LIMIT);
    }

    default List<Task> poll(int limit) {
        return poll(TaskConstants.DEFAULT_TYPE, TaskConstants.DEFAULT_LABEL, limit);
    }

    default List<Task> poll() {
        return poll(TaskConstants.DEFAULT_TYPE, TaskConstants.DEFAULT_LABEL, TaskConstants.DEFAULT_POLL_LIMIT);
    }

    int updateTask(List<Task> tasks);

    default int updateTask(Task task) {
        return updateTask(Collections.singletonList(task));
    }

    int archiving(int limit);

    default int archiving() {
        return archiving(TaskConstants.DEFAULT_ARCHIVING_LIMIT);
    }

    int retryProcessing(String updateTime, int limit);

    void createHistory(String tableName);
}
